{% comment 'header' %}
# This file is part of opentaps Smart Energy Applications Suite (SEAS).

# opentaps Smart Energy Applications Suite (SEAS) is free software:
# you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# opentaps Smart Energy Applications Suite (SEAS) is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public License
# along with opentaps Smart Energy Applications Suite (SEAS).
# If not, see <https://www.gnu.org/licenses/>.
{% endcomment %}

{% load static i18n %}

{% block content %}

<div id="map_{{weather_station.weather_station_code}}" style="height: 100%;width: 100%;"></div>

<script type="text/javascript">
function initMaps() {
    var latitude = {{ weather_station.latitude }};
    var longitude = {{ weather_station.longitude }};
    var description = "{{ weather_station.station_name }}";

    map_div = document.getElementById("map_{{weather_station.weather_station_code}}")
    if (map_div != null) {
        loc = {lat: latitude, lng: longitude}
        var map = new google.maps.Map(map_div, {zoom: 11, center: loc});

        var marker_params = {position: loc, map: map}
        if (description != 0) {
            marker_params.title = description
        }

        var marker = new google.maps.Marker(marker_params);
    }
}
</script>
<script async defer
    src="https://maps.googleapis.com/maps/api/js?key={{ GOOGLE_API_KEY }}&callback=initMaps">
</script>

{% endblock content %}
